import request from '@/util/axios';
import type {
  CommonResultType,
  ListData,
  ConfirmGetItem,
  QueryItem,
  SuccessResultType,
  CostSuccessResultType,
  CostDetailItem,
  CostDetailListData,
  DetailListData
} from './type.ts';

export enum API {
  // 获取资产成本列表
  LIST = 'http://192.168.43.220:9000/platform-entry/api/cost_aggregation/asset_cost/list',
  //获取详情
  DETAIL = 'http://27.115.98.190:31060/platform-entry/api/cost_aggregation/asset_cost/detail',
  //状态更新
  STATUS_UPDATE = 'http://27.115.98.190:31060/platform-entry/api/cost_aggregation/asset_cost/status/update',
  //资产成本明细更新
  UPDATE_LIST_DATA = 'http://27.115.98.190:31060/platform-entry/api/cost_aggregation/asset_cost/update'
}

/**
 * @method  getList 获取资产成本列表
 */
export const getList = (params: QueryItem): Promise<CommonResultType<ListData>> => {
  return request.get(API.LIST, { params });
};

/**
 * @method  costConfirm_get 允许入表
 */
export const costConfirm_get = (params: ConfirmGetItem): Promise<SuccessResultType<null>> => {
  return request.get(API.STATUS_UPDATE, { params });
};

/**
 * @method  getDetail 获取资产成本列表详情
 */
export const getDetail = (
  params: string
): Promise<CostSuccessResultType<CostDetailItem<CostDetailListData>>> => {
  return request.get(`${API.DETAIL}?id=${params}`);
};

/**
 * @method  createListDate 获取资产成本列表详情
 */
export const createListDate = (params: DetailListData): Promise<SuccessResultType<null>> => {
  return request.post(API.UPDATE_LIST_DATA, params);
};
